<?php

namespace Addons\Jininter\Controller;
use  Addons\Jininter\Controller\BaseController;
include_once 'simple_html_dom.php';  //导入html解析库
class JininterController extends BaseController{
    public function Index($id=0){
       
        $url ='http://www.szsyzx.com/About/ShowClass.asp?ClassID=1';
        $type = 'GET';
        $res =  $this ->inter_go_curl($url, $type);
        $res =iconv('gb2312','utf-8',$res);        //将抓取到的内容转为UTF-8编码 
        $html = str_get_html($res);      //从字符串中加载html文档  
        $result = $html->find('.listA');
       // $result = $html->find('a[href^=/About/ShowArticle.asp?ArticleID]');        //查找所有href属性以/jiuyexinxi/开头的a标签  
     
        foreach($result as $k=>$vo){                     //将查找出来的a标签的title和href属性值分别赋给二维数组$list  
           if(!($vo->title)) continue;
           $title = $vo ->title; 
           preg_match('/文章标题：(.*?)作/isU', $title, $matches );
           $list[$k][title]= $matches[1];
           
           $list[$k][href]=  implode('+',explode('/',$vo->href));     //将href的值以'/'为分割符分割成数组，并把数组用连接符'+'连接  
        }
        $html->clear();
        $this->assign('list_data',$list);             //将二维数组赋给变量list并在模板中输出  
        $this->display();  
    }
    
}
